<template>
	<view class="content">
		<view class="item" style="padding-top: 40rpx;margin-top: 0;">
			<view class="top" style="border-bottom: 2rpx solid rgba(0,0,0,0.102);">
				<view class="left flex">
					<image class="userAvatar2" :src="userInfo.avatar?userInfo.avatar:'../../../static/images/userAvatar.png'" mode="">
					</image>
					<view class="">
						<view class="flex">
							<text class=" bName">{{userInfo.nickname}}</text>
							<text class="vip" style="padding: 2rpx 20rpx;" v-if="levelName">{{levelName}}</text>
						</view>
						<view class="flex phoneBox" style="margin-top: 14rpx;">
							<image class="phoneIcon" src="@/static/images/phone.png" mode=""></image>
							<view class="bPhone">{{userInfo.phone.substr(0,3) + "****" + userInfo.phone.substr(7)}}</view>
						</view>
					</view>
				</view>
			</view>
			<view class="userItem flex-between">
				<view class="left">
					<view class="titleL">
						<image
							src="https://store-profit-system.oss-cn-shanghai.aliyuncs.com/qudaoguanli/jiaruwomen_icon13.png"
							mode=""></image>团队总人数
					</view>
					<view class="num">{{dataInfo.teamNumber || 0}}</view>
				</view>
				<view class="left">
					<view class="titleL">
						<image class="img"
							src="https://store-profit-system.oss-cn-shanghai.aliyuncs.com/qudaoguanli/jiaruwomen_icon11.png"
							mode=""></image>累计推广商家
					</view>
					<view class="num">{{dataInfo.storeNumber || 0}}</view>
				</view>
			</view>
		</view>
		<view class="bottom">
			<view class="title flex">
				<view class="lineText"></view>他的团队
			</view>
			<ren-dropdown-filter :filterData='filterData' :defaultIndex='defaultIndex'
				@onSelected='onSelected'></ren-dropdown-filter>
			<view class="" v-if="teamList.length>0">
				<view class="item" v-for="(item,index) in teamList" :key="index">
					<text class="time">加入时间:{{item.userInfo.createTime}}</text>
					<view class="top" style="padding-bottom: 0;">
						<view class="left flex">
							<image class="userAvatar2" :src="item.userInfo.avatar?item.userInfo.avatar:'../../../static/images/userAvatar.png'" mode="">
							</image>
							<view class="">
								<view class="flex">
									<text class=" bName">{{item.userInfo.nickname}}</text>
									<text class="vip" style="padding: 2rpx 20rpx;" v-if="item.platformLevelDO && item.platformLevelDO.levelName">{{item.platformLevelDO.levelName}}</text>
								</view>
							</view>
						</view>
						<view class="right">
							<view class="bTotal">累计推广: <text>{{item.pageNumber}}</text></view>
						</view>
					</view>
				</view>
			</view>
			<view class="" v-else>
				<emptyPage title="暂无信息～"></emptyPage>
			</view>
		</view>
	</view>
</template>

<script>
	import RenDropdownFilter from '@/components/ren-dropdown-filter/ren-dropdown-filter.vue'
	import emptyPage from '@/components/emptyPage.vue';
	import {
		getMyPromotionPage,
		getplatformLevel,
		getMyTeam
	} from '@/api/xing.js';
	export default {
		components:{
		    RenDropdownFilter,
			emptyPage
		},
		data() {
			return {
				userInfo: '',
				dataInfo: {},
				page: 1,
				limit: 10,
				teamList: [],
				levelId: '',
				filterData: JSON.parse(uni.getStorageSync('filterData')),
				defaultIndex: [0],
				totalPage: 0,
				levelName:''
			}
		},
		onLoad(option) {
			this.userInfo = JSON.parse(decodeURIComponent(option.userInfo))
			this.levelName = option.levelName
			console.log(this.levelName);
			console.log(option.levelName);
			console.log(this.userInfo);
			this.getTeam()
			this.getData()
		},
		methods: {
			// 获取团队列表
			getTeam() {
				let that = this;
				getMyPromotionPage({
					pageNum: that.page,
					pageSize: that.limit,
					uid: this.userInfo.uid,
					storeId: this.userInfo.msqStore?this.userInfo.msqStore.id:0,
					levelId: this.levelId
				}).then(res => {
					if (res.data && res.data.records.length > 0) {
						this.teamList = [...this.teamList, ...res.data.records];
						this.totalPage = res.data.pages
					}
				});
			},
			getData(){
				getMyTeam({
					uid: this.userInfo.uid,
					storeId: this.userInfo.msqStore?this.userInfo.msqStore.id:0,
				}).then(res=>{
					this.dataInfo = res.data
				})
			},
			onSelected(res) {
				this.teamList = []
				this.page = 1
				this.levelId = res[0][0].value
				this.getTeam();
			},
		},
		onReachBottom() {
			if (this.page < this.totalPage) {
				this.page++;
				this.getTeam();
			}
		},
	}
</script>

<style lang="scss">
	.content {
		padding: 24rpx 32rpx;
	}

	.userAvatar2 {
		width: 70rpx;
		height: 70rpx;
		border-radius: 50%;
		margin-right: 12rpx;
	}

	.top {
		width: 100%;
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding-bottom: 24rpx;

		.left {
			.phoneIcon {
				width: 23rpx;
				height: 28rpx;
				margin-right: 6rpx;
			}

			.phoneBox {
				.text {
					;
					font-weight: 700;
					font-size: 24rpx;
					color: rgba(255, 255, 255, 0.66);
				}
			}

			.vip {
				border-radius: 4rpx 4rpx 20rpx 4rpx;
				font-weight: 400;
				font-size: 24rpx;
				color: #28314C;
				padding: 6rpx 20rpx;
				background: linear-gradient(91deg, #F2F2F4 0%, #CBCED4 100%);
			}

			.mr32 {
				margin-right: 32rpx;
				color: #FFFFFF;
				font-family: Alibaba PuHuiTi 2.0, Alibaba PuHuiTi 20;
				font-weight: normal;
				font-size: 32rpx;
			}

			.ID {
				;
				font-weight: bold;
				font-size: 24rpx;
				color: #FFFFFF;
				background: rgba(255, 255, 255, 0.37);
				border-radius: 8rpx;
				padding: 2rpx 10rpx;
				margin-left: 12rpx;
			}
		}

		.right {
			display: flex;
			flex-direction: column;
			align-items: center;

			.qrcode {
				width: 48rpx;
				height: 48rpx;
				margin-bottom: 8rpx;
			}

			.text {
				font-family: PingFang SC Medium, PingFang SC Medium;
				font-size: 24rpx;
				color: #FFFFFF;
				font-weight: 400;
			}
		}
	}

	.flex {
		display: flex;
		align-items: center;
	}

	.flex-all-center {
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.flex-between {
		display: flex;
		align-items: flex-start;
		justify-content: space-between;
	}

	.bName {
		color: #28314C;
		margin-right: 24rpx;
		font-family: Alibaba PuHuiTi 2.0, Alibaba PuHuiTi 20;
		font-weight: 700;
		font-size: 28rpx;
	}

	.bPhone {
		;
		font-weight: 700;
		font-size: 24rpx;
		color: #637697;
	}

	.item {
		position: relative;
		margin-top: 24rpx;
		padding: 64rpx 24rpx 26rpx;
		background: linear-gradient(180deg, #CCE3FD 0%, #F4F9FF 51%, #FFFFFF 100%);
		box-shadow: 0px 6px 12px 0px rgba(204, 204, 204, 0.1569);
		border-radius: 12rpx;

		.time {
			position: absolute;
			top: 0;
			left: 0;
			background: #0077FF;
			border-radius: 12rpx 0px 16rpx 0px;
			font-size: 20rpx;
			color: #FFFFFF;
			padding: 8rpx 40rpx 8rpx 24rpx;
		}

		.bottom {
			.bItem {
				font-size: 24rpx;
				color: #637697;

				.num {
					;
					font-weight: 700;
					font-size: 40rpx;
					color: #2393FF;

					.pIcon {
						font-size: 24rpx;
					}
				}

			}

			.btn {
				width: 178rpx;
				height: 62rpx;
				line-height: 62rpx;
				background: #0077FF;
				border-radius: 42rpx;
				text-align: center;
				font-size: 24rpx;
				color: #FFFFFF;
			}
		}
	}

	.bTotal {
		font-size: 24rpx;
		color: #637697;

		text {
			font-family: DIN;
			font-weight: 700;
			font-size: 32rpx;
			color: #637697;
		}
	}

	.userItem {
		margin-top: 32rpx;

		.left {
			width: 307rpx;
			height: 122rpx;
			background: #F8FBFF;
			border-radius: 12rpx;
			padding: 14rpx 28rpx 0;

			.titleL {
				display: flex;
				align-items: center;
				font-size: 24rpx;
				color: #28314C;

				image {
					width: 30rpx;
					height: 24rpx;
					margin-right: 6rpx;
				}

				.img {
					width: 30rpx;
					height: 27rpx;
					margin-right: 4rpx;
				}
			}

			.num {
				;
				font-weight: 700;
				font-size: 56rpx;
				color: #28314C;
				margin-left: 32rpx;
			}
		}
	}

	.bottom {
		margin-top: 24rpx;
		background: #FFFFFF;
		box-shadow: 0px 6px 12px 0px rgba(204, 204, 204, 0.1569);
		border-radius: 12rpx;
		padding: 24rpx;

		.title {
			font-weight: 700;
			font-size: 32rpx;
			color: #28314C;
			margin-bottom: 24rpx;
			font-family: "Alibaba PuHuiTi 2.0-85 Bold"
		}

		.lineText {
			width: 8rpx;
			height: 34rpx;
			background: #2393FF;
			border-radius: 4px 4px 4px 4px;
			margin-right: 12rpx;
		}
	}

	.sort {
		font-size: 24rpx;
		color: #637697;
		padding: 0rpx 0 8rpx 0;
		border-bottom: 2rpx solid #E5E5E5;

		image {
			width: 23rpx;
			height: 21rpx;
			margin-left: 10rpx;
		}
	}
</style>